<template>
  <div>
    <!-- 面包屑导航区域 -->
    <Break></Break>
    <el-card>
      <div id="myChart" :style="{ width: '700px', height: '400px' }"></div>
    </el-card>
  </div>
</template>

<script>
import reoprtsAPI from "../../http/API/reports"
import Break from "../bread";
import _ from "lodash";
export default {
  components: {
    Break,
  },
  data() {
    return {
      options: {
        title: {
          text: "用户来源",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#E9EEF3",
            },
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            boundaryGap: false,
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
      },
    };
  },

  mounted() {
    // 基于准备好的dom，初始化echarts实例
    let myChart = this.$echarts.init(document.getElementById("myChart"));
    reoprtsAPI.getreports().then((res) => {
      this.reportsList = res.data.data;
      //准备数据和配置项
      const result = _.merge(res.data.data, this.options);
      // 展示数据
      myChart.setOption(result);
    });
  },
  methods: {},
};
</script> 


<style scoped>
.el-card {
  margin-top: 15px;
}
</style>
